<?php
class Search_Widget extends WP_Widget {
  
  	function Search_Widget() {	
  		$widget_ops = array( 'classname' => 'Search_Widget', 'description' =>  __( "Search Widget for Locality Theme" , 'locality')  );
  		$this->WP_Widget( 'Search_Widget', 'Locality: Search Widget', $widget_ops);
  	}
  	
  	function widget($args, $instance) { 
		
		extract($args);
						
		$title = apply_filters('widget_title', $instance['title']);		
		if ( empty($title) ) $title = false;	
		
		echo $before_widget;	
				?>	
                      <div class="advancesearch-wrapper">
                            <div class="search-options">
                                  <div class="advancesearch-head">
                                        <?php
		                                if($title):
											echo $before_title;
												echo $title;
											echo $after_title;	
										endif;
										?>
                                  </div>
                                  <form class="advance-search-form" action="<?php echo home_url(); ?>" method="get">
                                    <?php get_template_part( 'advance-search' ); ?>
                                 </form>
                            </div> 
                     </div>	                         						
				<?php		
		
		echo $after_widget;
	}
	

	function form($instance) 
	{	
		
		$instance = wp_parse_args( (array) $instance, array( 'title' => 'Search Widget' ) );
		
        $title= esc_attr($instance['title']);		
		
		?>
			<p>
	            <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','locality'); ?></label>
	            <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
	        </p>			
		<?php
	}

	function update($new_instance, $old_instance) 
	{
        $instance = $old_instance;		
		
        $instance['title'] = strip_tags($new_instance['title']);
		
        return $instance;

    }
	
  
  }